//
//  FindViewController.m
//  BrushFace
//
//  Created by timer_q on 15/12/1.
//  Copyright © 2015年 Zzz. All rights reserved.
//

#import "FindViewController.h"
#import "Find_Cell.h"
#import "ActiveViewController.h"
#import "MessageViewController.h"
#import "NavHelper.h"
#import "EngageBeginnersVC.h"

@interface FindViewController ()<UITableViewDelegate,UITableViewDataSource>
{
    NSMutableArray *_itemArray;
    BOOL _isMessage;
}
@end

@implementation FindViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self someDataInit];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(isMessage) name:@"haveNewMessage" object:nil];
    

    
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
    self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];
}
- (void)viewDidDisappear:(BOOL)animated{
    [super viewDidDisappear:animated];
}

#pragma mark - initData
- (void)someDataInit{
    _itemArray = [[NSMutableArray alloc] initWithObjects:@{@"img":@"message_item@2x.png",@"title":@"消息中心"},@{@"img":@"huodong@2x.png",@"title":@"活动"},@{@"img":@"xinshou@2x.png",@"title":@"新手引导"}, nil];
    [_find_TableView reloadData];
    [self.navBar setTitle:@"发现"];
    [self.navBar setHideLeftBtn:YES];
}

#pragma mark - TableViewDataSource andDelegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return _itemArray.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellId = @"Find_Cell";
    Find_Cell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:cellId owner:self options:nil] lastObject];
    }
    cell.cellTitle.text = [[_itemArray objectAtIndex:indexPath.section] objectForKey:@"title"];
    cell.cellImage.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@",[[_itemArray objectAtIndex:indexPath.section] objectForKey:@"img"]]];
    cell.cellImage.contentMode = UIViewContentModeScaleAspectFill;
    cell.numLabel.hidden = YES;
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 40;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 10;
}
- (void)isMessage
{
    _isMessage = YES;
    [_find_TableView reloadData];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    switch (indexPath.section) {
#pragma mark-------qiweipeng
        case 0:
        {
            _isMessage = NO;
            [NavHelper gotoFindMsgVC];
            [tableView reloadData];
        }
            break;
#pragma mark------------------
            
        case 1:
        {
            [NavHelper gotoFindActiveVC];
        }
            break;
        case 2:
        {
            EngageBeginnersVC *engageVC = [[EngageBeginnersVC alloc] init];
            [engageVC setHidesBottomBarWhenPushed:YES];
            [self.navigationController pushViewController:engageVC animated:YES];
        }
            break;
        default:
            break;
    }

    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
